package chpt08;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;

public class BufferedTime {
	public static void main(String[] args) throws IOException {
		long begin = System.currentTimeMillis();
		PrintWriter pw=null;
		try {
			pw = new PrintWriter("d:/test.txt");
			for(int i = 0;i<10000000;i++){
			pw.println(new Random().nextInt(100000));
		}
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}finally{
			pw.close();
		}
		long end = System.currentTimeMillis();
		System.out.println("last "+(end-begin));
		System.out.println("write using PrintWriter done");
		
		
		begin = System.currentTimeMillis();
		FileReader fr=null;
		try{
		fr=new FileReader("d:/Studs.txt");
		@SuppressWarnings("resource")
		BufferedReader br = new BufferedReader(fr);
		String line = null;
		while ((line = br.readLine()) != null)
			System.out.println(line);
		}finally{
			fr.close();
		}
		end = System.currentTimeMillis();
		System.out.println("last "+(end-begin));
		System.out.println("write using PrintWriter done");
	}
}
